﻿@using System.Web.Mvc.Html;
@using System.Web.WebPages.Html;
@using System.Web.Mvc;
@using DddCms.Models.UIComponent.Window;
@using DddCms.Presentation.Areas.DddCms.Models.UIComponent.Tooltip;

@helper Tooltip(Func<TooltipViewModelBuilder, TooltipViewModelBuilder> funcBuilder)
{
    TooltipViewModel viewmodel = funcBuilder(new TooltipViewModelBuilder()).Build();
    string positionMy = "";
    string positionAt = "";
    switch (viewmodel.Position)
    {
        case TooltipPosition.BottomLeft:
            positionMy = "right top";
            positionAt = "left bottom";
            break;
        case TooltipPosition.BottomRight:
            positionMy = "left top";
            positionAt = "right bottom";
            break;
        case TooltipPosition.TopLeft:
            positionMy = "right bottom";
            positionAt = "left top";
            break;
        case TooltipPosition.TopRight:
            positionMy = "left bottom";
            positionAt = "right top";
            break;
        default:
            throw new Exception("Type inconnue");
            break;
    }
    
    <div class="tooltip" data-position-my="@positionMy" data-position-at="@positionAt">
        <span class="tooltip-content">@viewmodel.Content</span>
        <div class="tooltip-window">
            @WindowHelpers.WindowFunc(w => w
                .Title(viewmodel.Title)
                .Style(viewmodel.WindowStyle)
                .Position(WindowPositionViewModel.Left)
                .Content(viewmodel.Message))
        </div>
    </div>
}